package designPattern.bridge桥接模式.def01;

public class BridgeTest {
    public static void main(String[] args) {
        Implementor cia = new ConcreteImplementorA();
        Abstraction abs = new RefinedAbstraction(cia);
        abs.Operation();

        System.out.println();

        Implementor cib = new ConcreteImplementorB();
        Abstraction abs02 = new RefinedAbstraction(cia);
        abs02.Operation();
    }
}

//实现化角色
interface Implementor {
    public void OperationImpl();
}

//具体实现化角色A
class ConcreteImplementorA implements Implementor {
    public void OperationImpl() {
        System.out.println("具体实现化(Concrete Implementor A)角色被访问");
    }
}
//具体实现化角色B
class ConcreteImplementorB implements Implementor {
    public void OperationImpl() {
        System.out.println("具体实现化(Concrete Implementor B)角色被访问");
    }
}

//抽象化角色
abstract class Abstraction {
    protected Implementor imple;

    protected Abstraction(Implementor imple) {
        this.imple = imple;
    }

    public abstract void Operation();
}

//扩展抽象化角色
class RefinedAbstraction extends Abstraction {
    protected RefinedAbstraction(Implementor imple) {
        super(imple);
    }

    public void Operation() {
        System.out.println("扩展抽象化(Refined Abstraction)角色被访问");
        imple.OperationImpl();
    }
}
